<html xmlns:th="http://www.thymeleaf.org"><!-- Thymeleaf的命名空间，将静态页面转换为动态的视图 -->
    <head>
        <meta content="text/html;charset=UTF-8"/>
        <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
        <title th:utext="#{label.badUser.title}">bad user</title>
    </head>
    <body>
        <div class="container">
            <div th:if="${errMsg}">
                <h1 class="alert alert-danger" th:text="${errMsg}">error</h1>
            </div>
            <br/>
            <a class="btn btn-default" th:href="@{/registration.html}" th:utext="#{label.form.loginSignUp}">signup</a>

            <div th:if="${expired}">
                <br/>
                <h1 th:utext="#{label.form.resendRegistrationToken}">resend</h1>
                <button class="btn btn-default" onclick="resendToken()">resend</button>

            </div>
        </div>

        <script th:src="@{/js/jquery-3.5.1.min.js}" type="text/javascript"></script>
        <script th:src="@{/js/bootstrap.min.js}" type="text/javascript"></script>
        <script th:inline="javascript">
            var serverContext = [[@{/}]];

            function resendToken() {
                var token = [[${token}]];
                $.get(serverContext + "user/resendRegistrationToken?token="+token, function(data){
                    console.log('' + data.message);
                    window.location.href = serverContext +"login?message=" + data.message;
                })
                .fail(function(data) {
                    if(data.responseJSON.error.indexOf("MailError") > -1)
                    {
                        window.location.href = serverContext + "emailError.html";
                    }
                    else{
                        window.location.href = serverContext + "login?message=" + data.responseJSON.message;
                    }
                });
            }

            $(document).ajaxStart(function() {
                $("title").html("LOADING ...");
            });
        </script>
    </body>
</html>
